//
//  ViewControllerManager.m
//  PlayBall
//
//  Created by Edward Zhang on 12-5-4.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "JddViewControllerManager.h"
#import "JddUserProfile.h"
#import "JddGlobal.h"

@implementation JddViewControllerManager

@synthesize navigationController;

SHARED_INSTANCE_DEFINE(JddViewControllerManager)




- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
//    [JddCommonFunction setWaitingViewHidden:YES fromController:nil];
//    [[JddGlobalParameter sharedInstance].operationQueue cancelAllOperations];
    [[JddGlobal sharedInstance].tabBar setTabItemFiveMatchSelected:NO];
    switch (item.tag) {
        case 1://lottery hall
            [self pushViewControllerWithIndex:CONTROLLER_LOTTERY_HALL
                               fromController:nil 
                                   withObject:nil 
                                withObject2:nil];
            break;
        case 2://togetherBuy
            [self pushViewControllerWithIndex:CONTROLLER_TOGETHER_BUY
                               fromController:nil
                                   withObject:nil
                                  withObject2:nil];
            break;
        case 4://service
            [self pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN
                               fromController:nil
                                   withObject:nil
                                  withObject2:nil];
            break;
        case 3://Five Match
            /*
            [self pushViewControllerWithIndex:CONTROLLER_SCORE
                               fromController:nil
                                   withObject:nil
                                  withObject2:nil];
             */
            [[JddGlobal sharedInstance].tabBar setTabItemFiveMatchSelected:YES];
            
            [self pushViewControllerWithIndex:CONTROLLER_FIVE_MATCH
                               fromController:nil
                                   withObject:nil
                                  withObject2:nil];
            
            
            /*
            if ([JddCommonFunction isLogin]) {
                [self pushViewControllerWithIndex:CONTROLLER_FIVE_MATCH
                                   fromController:nil
                                       withObject:nil
                                      withObject2:nil];
            }else{
                [self pushViewControllerWithIndex:CONTROLLER_LOGIN
                                   fromController:nil
                                       withObject:nil
                                      withObject2:nil];
            }
             */
            break;
            
        case 5://user center
            [self pushViewControllerWithIndex:CONTROLLER_USER_CENTER
                               fromController:nil
                                   withObject:nil
                                  withObject2:nil];
            break;
        default:
            break;
    }
}

- (void)pushViewControllerWithIndex:(NSInteger)controllerIndex fromController:(UIViewController*)fromController withObject:(id)userInfo withObject2:(id)userInfo2
{
    switch (controllerIndex) {
            
        case CONTROLLER_UNION_LIANJIE:
            if (!_myLinkController) {
                _myLinkController = [MyLinkViewController sharedInstance];
            }
            _wodeYejicControlller.fromController = fromController;
            [_myLinkController setJddTabBarHidden:YES];
            [self pushViewController:_myLinkController];
            break;
        case CONTROLLER_UNION_MYYEJI:
            if (!_wodeYejicControlller) {
                _wodeYejicControlller = [WoDeYeViewController sharedInstance];
            }
            _wodeYejicControlller.fromController = fromController;
            [self pushViewController:_wodeYejicControlller];
            break;
        case CONTROLLER_UNION_MYLIST:
            if (!_unionListController) {
                _unionListController = [UnionListViewController sharedInstance];
            }
            _unionListController.fromController = fromController;
            [self pushViewController:_unionListController];
            break;
        case CONTROLLER_REGISTER:
            _registerController = [[JddRegisterViewController alloc] init];
            _registerController.fromController = fromController;
            [self pushViewController:_registerController];
            break;
        case CONTROLLER_LOGIN:
            _loginController = [[JddLoginViewController alloc] init];
            _loginController.fromController = fromController;
            _loginController.hideBackItem = self.hideBackItem;
            [self pushViewController:_loginController animated:!self.hideBackItem];
            self.hideBackItem = NO;
            break;
        case CONTROLLER_LOTTERY_HALL:
            if (!_lotteryHallController) {
                _lotteryHallController = [JddLotteryHallViewController sharedInstance];
            }
            _lotteryHallController.fromController = fromController;
            [self pushViewController:_lotteryHallController];
            break;
//        case CONTROLLER_LOTTERY_SERVICE:
//            if (!_serviceController) {
//                _serviceController = [JddServiceViewController sharedInstance];
//            }
//            _serviceController.fromController = fromController;
//            [self pushViewController:_serviceController];
//            break;
        case CONTROLLER_LOTTERY_OPEN:
            if (!_lotteryOpernController) {
                _lotteryOpernController = [JddLotteryOpenViewController sharedInstance];
            }
            _lotteryOpernController.fromController = fromController;
            [self pushViewController:_lotteryOpernController];
            break;
        case CONTROLLER_PROFILE_UPDATE:
            if (!_profileUpdateController) {
                _profileUpdateController = [JddProfileUpdateViewController sharedInstance];
            }
            _profileUpdateController.fromController = fromController;
            [self pushViewController:_profileUpdateController];
            break;
        case CONTROLLER_SETTING:
            if (!_settingController) {
                _settingController = [JddSettingViewController sharedInstance];
            }
            _settingController.fromController = fromController;
            [self pushViewController:_settingController];
            break;
        case CONTROLLER_SCORE:
            if (!_scoreController) {
                _scoreController = [JddScoreViewController  sharedInstance];
            }
            _scoreController.fromController = fromController;
            [self pushViewController:_scoreController];
            break;
        case CONTROLLER_USER_CENTER:
            if (!_userCenterController) {
                _userCenterController = [JddUserCenterViewController sharedInstance];
            }
            _userCenterController.fromController = fromController;
            [self pushViewController:_userCenterController];
            break;
        case CONTROLLER_BUY_HISTORY:
            if (!_buyHistoryController) {
                _buyHistoryController = [JddUCBuyHistoryViewController sharedInstance];
            }
            _buyHistoryController.fromController = fromController;
            _buyHistoryController.LotID = [userInfo intValue];
            [self pushViewController:_buyHistoryController];
            break;
        case CONTROLLER_BUY_DETAIL_DIGITAL:
            _buyDetailDigitalController = [[JddBuyDetailDigitalViewController alloc] init];
            _buyDetailDigitalController.fromController = fromController;
            _buyDetailDigitalController.realString = (NSString*)userInfo;
            [self pushViewController:_buyDetailDigitalController];
            break;
        case CONTROLLER_BUY_DETAIL_DIGITAL_OLD:
            if (!_oldbuyDetailDigitalController) {
                _oldbuyDetailDigitalController = [JddOldBuyDetailDigitalViewController sharedInstance];
            }
            _oldbuyDetailDigitalController.fromController = fromController;
            _oldbuyDetailDigitalController.realString = (NSString*)userInfo;
            [self pushViewController:_oldbuyDetailDigitalController];
            break;
        case CONTROLLER_FOLLOW_NUMBER_HISTORY:
            if (!_followNumberHistoryController) {
                _followNumberHistoryController = [JddFollowNumberHistoryViewController sharedInstance];
            }
            _followNumberHistoryController.fromController = fromController;
            [self pushViewController:_followNumberHistoryController];
            break;
        case CONTROLLER_FOLLOW_NUMBER_DETAIL:
            if (!_followNumberDetailController) {
                _followNumberDetailController = [JddFollowNumberDetailViewController sharedInstance];
            }
            _followNumberDetailController.fromController = fromController;
            _followNumberDetailController.realResult = (NSString *)userInfo;
            _followNumberDetailController.charseId = (NSString *)userInfo2;
            [self pushViewController:_followNumberDetailController];
            break;
        case CONTROLLER_ACCOUNT_DETAIL:
            if (!_accountDetailController) {
                _accountDetailController = [JddAccountDetailViewController sharedInstance];
            }
            _accountDetailController.fromController = fromController;
            [self pushViewController:_accountDetailController];
            break;
        case CONTROLLER_SELECT_RECHARGE_WAY:
            if (!_rechargeWaySelectController) {
                _rechargeWaySelectController = [JddRechargeWaySelectViewController sharedInstance];
            }
            _rechargeWaySelectController.fromController = fromController;
            [self pushViewController:_rechargeWaySelectController];
            break;
        case CONTROLLER_ALIPAY_RECHARGE:
            if (!_alipayRechargeController) {
                _alipayRechargeController = [JddAlipayRechargeViewController sharedInstance];
            }
            _alipayRechargeController.fromController = fromController;
            [self pushViewController:_alipayRechargeController];
            break;
        case CONTROLLER_UM_RECHARGE:
            if(!_umRechargeController){
                _umRechargeController = [JddUmRechargeViewController sharedInstance];
            }
            _umRechargeController.fromController = fromController;
            [self pushViewController:_umRechargeController];
            break;
        case CONTROLLER_WITHDRAW:
            if (!_withdrawController) {
                _withdrawController = [JddWithdrawViewController sharedInstance];
            }
            _withdrawController.fromController = fromController;
            [self pushViewController:_withdrawController];
            break;
        case CONTROLLER_BIND_MOBILE:
            if (!_bindMobileContoller) {
                _bindMobileContoller = [JddReBindMobileViewController sharedInstance];
            }
            _bindMobileContoller.fromController = fromController;
            [self pushViewController:_bindMobileContoller];
            break;
        case CONTROLLER_BIND_MOBILE_SUCCEEDED:
            if (!_bindMobileSucceededController) {
                _bindMobileSucceededController = [JddBindMobileSucceedViewController sharedInstance];
            }
            _bindMobileSucceededController.fromController = fromController;
            [self pushViewController:_bindMobileSucceededController];
            break;
        case CONTROLLER_BIND_CARD_USER_INFO:
            if (!_bindCardController) {
                _bindCardController = [JddBindCardViewController sharedInstance];
            }
            _bindCardController.fromController = fromController;
            [self pushViewController:_bindCardController];
            break;
        case CONTROLLER_BIND_CARD_CARD_INFO:
            if (!_bindCardNextController) {
                _bindCardNextController = [JddBindCardNextViewController sharedInstance];
            }
            _bindCardNextController.fromController = fromController;
            [self pushViewController:_bindCardNextController];
            break;
        case CONTROLLER_BIND_CARD_SUCCESSED:
            if (!_bindCardSucceedViewController) {
                _bindCardSucceedViewController = [JddBindCardSucceedViewController sharedInstance];
            }
            _bindCardSucceedViewController.fromController = fromController;
            [self pushViewController:_bindCardSucceedViewController];
            break;
        case CONTROLLER_MODIFY_PASSWORD:
            if (!_modifyPasswordController) {
                _modifyPasswordController = [JddModifyPasswordViewController sharedInstance];
            }
            _modifyPasswordController.fromController = fromController;
            [self pushViewController:_modifyPasswordController];
            break;
        case CONTROLLER_PICK_NUM_SHUANGSEQIU:
            if (!_pickNumShuangSeQiuController) {
                _pickNumShuangSeQiuController = [JddPickNumShuangSeQiuViewController sharedInstance];
            }
            _pickNumShuangSeQiuController.fromController = fromController;
            [self pushViewController:_pickNumShuangSeQiuController];
            break;
        case CONTROLLER_PICK_NUM_SHUANGSEQIU_LIST:
            if (!_pickNumShuangSeQiuListController) {
                _pickNumShuangSeQiuListController = [JddPickNumShuangSeQiuListViewController sharedInstance];
            }
            [_pickNumShuangSeQiuListController numberFromArray:(NSArray *)userInfo];
            _pickNumShuangSeQiuListController.fromController = fromController;
            [self pushViewController:_pickNumShuangSeQiuListController];
            break;
        case CONTROLLER_PICK_NUM_7L:
            if(!_pickNum7lViewController){
                _pickNum7lViewController = [JddPickNum7lcViewController sharedInstance];
            }
            _pickNum7lViewController.fromController = fromController;
            [self pushViewController:_pickNum7lViewController];
            break;
        case CONTROLLER_PICK_NUM_7L_LIST:
            if (!_pickNum7lcListViewController) {
                _pickNum7lcListViewController = [JddPickNum7lcListViewController sharedInstance];
            }
            [_pickNum7lcListViewController numberFromArray:(NSArray *)userInfo];
            _pickNum7lcListViewController.fromController = fromController;
            [self pushViewController:_pickNum7lcListViewController];
            break;
        case CONTROLLER_PICK_NUM_7X:
            if(!_pickNum7xcViewController){
                _pickNum7xcViewController = [JddPickNum7xcViewController sharedInstance];
            }
            _pickNum7xcViewController.fromController = fromController;
            [self pushViewController:_pickNum7xcViewController];
            break;
        case CONTROLLER_PICK_NUM_7X_LIST:
            if (!_pickNum7xcListViewController) {
                _pickNum7xcListViewController = [JddPickNum7xcListViewController sharedInstance];
            }
            [_pickNum7xcListViewController numberFromArray:(NSArray *)userInfo];
            _pickNum7xcListViewController.fromController = fromController;
            [self pushViewController:_pickNum7xcListViewController];
            break;
            //福彩3D选号
        case CONTROLLER_PICK_NUM_FC3D:
            if (!_pickNumFc3dController) {
                _pickNumFc3dController = [JddPickNumFC3DViewController sharedInstance];
            }
            _pickNumFc3dController.fromController = fromController;
            [self pushViewController:_pickNumFc3dController];
            break;
            //福彩3D选号列表
        case CONTROLLER_PICK_NUM_FC3D_LIST:
            if (!_pickNumFc3dListController) {
                _pickNumFc3dListController = [JddPickNumFC3DListViewController sharedInstance];
            }
            _pickNumFc3dListController.PlayMethodTemp = [userInfo2 intValue];
            [_pickNumFc3dListController numberFromArray:(NSArray *)userInfo];
            _pickNumFc3dListController.fromController = fromController;
            [self pushViewController:_pickNumFc3dListController];
            break;
            //排列3选号
        case CONTROLLER_PICK_NUM_P3:
            if (!_pickNumP3ViewController) {
                _pickNumP3ViewController = [JddPickNumP3ViewController sharedInstance];
            }
            _pickNumP3ViewController.fromController = fromController;
            [self pushViewController:_pickNumP3ViewController];
            break;
            //排列3选号列表
        case CONTROLLER_PICK_NUM_P3_LIST:
            if (!_pickNumP3ListViewController) {
                _pickNumP3ListViewController = [JddPickNumP3ListViewController sharedInstance];
            }
            _pickNumP3ListViewController.PlayMethodTemp = [userInfo2 intValue];
            [_pickNumP3ListViewController numberFromArray:(NSArray *)userInfo];
            _pickNumP3ListViewController.fromController = fromController;
            [self pushViewController:_pickNumP3ListViewController];
            break;
            //排列5选号
        case CONTROLLER_PICK_NUM_P5:
            if (!_pickNumP5ViewController) {
                _pickNumP5ViewController = [JddPickNumP5ViewController sharedInstance];
            }
            _pickNumP5ViewController.fromController = fromController;
            [self pushViewController:_pickNumP5ViewController];
            break;
            //排列5选号列表
        case CONTROLLER_PICK_NUM_P5_LIST:
            if (!_pickNumP5ListViewController) {
                _pickNumP5ListViewController = [JddPickNumP5ListViewController sharedInstance];
            }
            [_pickNumP5ListViewController numberFromArray:(NSArray *)userInfo];
            _pickNumP5ListViewController.fromController = fromController;
            [self pushViewController:_pickNumP5ListViewController];
            break;
        case CONTROLLER_PICK_NUM_DALETOU:
            if (!_pickNumDaLeTouController) {
                _pickNumDaLeTouController = [JddPickNumDaLeTouViewController sharedInstance];
            }
            _pickNumDaLeTouController.fromController = fromController;
            [self pushViewController:_pickNumDaLeTouController];
            break;
        case CONTROLLER_PICK_NUM_DALETOU_LIST:
            if (!_pickNumDaLeTouListController) {
                _pickNumDaLeTouListController = [JddPickNumDaLeTouListViewController sharedInstance];
            }
            [_pickNumDaLeTouListController numberFromArray:(NSArray *)userInfo];
            _pickNumDaLeTouListController.fromController = fromController;
            [self pushViewController:_pickNumDaLeTouListController];
            break;
        case CONTROLLER_PICK_NUM_11s5:
            if (!_pickNum11s5Controller) {
                _pickNum11s5Controller = [JddPickNum11s5ViewController sharedInstance];
            }
            _pickNum11s5Controller.fromController = fromController;
            [self pushViewController:_pickNum11s5Controller];
            break;
        case CONTROLLER_PICK_NUM_11S5_LIST:
            if (!_pickNum11s5ListController) {
                _pickNum11s5ListController = [JddPickNum11s5ListViewController sharedInstance];
            }
            [_pickNum11s5ListController viewDidLoad];
            _pickNum11s5ListController.PlayMethodTemp = [userInfo2 intValue];
            [_pickNum11s5ListController numberFromArray:(NSArray *)userInfo];
            
            _pickNum11s5ListController.fromController = fromController;
            [self pushViewController:_pickNum11s5ListController];
            break;
        case CONTROLLER_PICK_NUM_SPORT:
            _pickNumSportController = [[JddPickNumSportViewController alloc] init];
            _pickNumSportController.fromController = fromController;
            [self pushViewController:_pickNumSportController];
            break;
        case CONTROLLER_PICK_NUM_SPORT_LIST:
            _pickNumSportListViewController = [[JddPickNumSportListViewController alloc] init];
            _pickNumSportListViewController.fromController = fromController;
            _pickNumSportListViewController.endTime = (NSDate*) [(NSArray *)userInfo2 objectAtIndex:0];
            _pickNumSportListViewController.playId = [[(NSArray *)userInfo2 objectAtIndex:1] intValue];
            _pickNumSportListViewController.numberArray = [NSMutableArray arrayWithArray:(NSMutableArray*)userInfo];
            [self pushViewController:_pickNumSportListViewController];
            break;
        case CONTROLLER_PICK_NUM_BD:
                _pickNumBDViewController = [[JddPickNumBDViewController  alloc] init];
            _pickNumBDViewController.fromController = fromController;
            [self pushViewController:_pickNumBDViewController];
            break;
        case CONTROLLER_PICK_NUM_BD_LIST:
            _pickNumBDListViewController = [[JddPickNumBDListViewController alloc] init];
            _pickNumBDListViewController.fromController = fromController;
            _pickNumBDListViewController.endTime = (NSDate*) [(NSArray *)userInfo2 objectAtIndex:0];
            _pickNumBDListViewController.playId = [[(NSArray *)userInfo2 objectAtIndex:1] intValue];
            _pickNumBDListViewController.numberArray = [NSMutableArray arrayWithArray:(NSMutableArray*)userInfo];
            [self pushViewController:_pickNumBDListViewController];
            break;
        case CONTROLLER_PICK_NUM_SFC:
            if (!_pickNumSFCViewController) {
                _pickNumSFCViewController = [JddPickNumSFCViewController sharedInstance];
            }
            _pickNumSFCViewController.fromController = fromController;
            [self pushViewController:_pickNumSFCViewController];
            break;
        case CONTROLLER_PICK_NUM_SFC_LIST:
            if (!_pickNumSFCListViewController) {
                _pickNumSFCListViewController = [JddPickNumSFCListViewController sharedInstance];
            }
            _pickNumSFCListViewController.fromController = fromController;
            _pickNumSFCListViewController.endTime = (NSString*) userInfo2;
            _pickNumSFCListViewController.numberArray = [NSMutableArray arrayWithArray:(NSMutableArray*)userInfo];
            [self pushViewController:_pickNumSFCListViewController];
            break;
        case CONTROLLER_PICK_NUM_RX9:
            if (!_pickNumRX9ViewController) {
                _pickNumRX9ViewController = [JddPickNumRX9ViewController sharedInstance];
            }
            _pickNumRX9ViewController.fromController = fromController;
            [self pushViewController:_pickNumRX9ViewController];
            break;
        case CONTROLLER_PICK_NUM_RX9_LIST:
            if (!_pickNumRX9ListViewController) {
                _pickNumRX9ListViewController = [JddPickNumRX9ListViewController sharedInstance];
            }
            _pickNumRX9ListViewController.fromController = fromController;
            _pickNumRX9ListViewController.endTime = (NSString*) userInfo2;
            _pickNumRX9ListViewController.numberArray = [NSMutableArray arrayWithArray:(NSMutableArray*)userInfo];
            [self pushViewController:_pickNumRX9ListViewController];
            break;
        case CONTROLLER_PICK_NUM_BASKETBALL:
            _pickNumBasketBallViewController = [[JddPickNumBasketBallViewController alloc] init];
            _pickNumBasketBallViewController.fromController = fromController;
            [self pushViewController:_pickNumBasketBallViewController];
            break;
        case CONTROLLER_PICK_NUM_BASKETBALL_LIST:
                _pickNumBasketBallListViewController = [[JddPickNumBasketBallListViewController alloc] init];
            _pickNumBasketBallListViewController.fromController = fromController;
            _pickNumBasketBallListViewController.playId = [[(NSArray *)userInfo2 objectAtIndex:1] intValue];
            _pickNumBasketBallListViewController.endTime = (NSDate*) [(NSArray *)userInfo2 objectAtIndex:0];
            _pickNumBasketBallListViewController.numberArray = [NSMutableArray arrayWithArray:(NSMutableArray*)userInfo];
            [self pushViewController:_pickNumBasketBallListViewController];
            break;
        case CONTROLLER_LOTTERY_OPEN_DETAIL:
            if (!_lotteryOpenViewDetailController) {
                _lotteryOpenViewDetailController = [JddLotteryOpenViewDetailController sharedInstance];
            }
            _lotteryOpenViewDetailController.fromController = fromController;
            _lotteryOpenViewDetailController.realResult =(NSString*)userInfo;
            _lotteryOpenViewDetailController.jx = [NSString stringWithFormat:@"%@期",(NSString*)userInfo2];
            [self pushViewController:_lotteryOpenViewDetailController];
            break;
        case CONTROLLER_LOTTERY_OPEN_DETAIL_BD:
            if(!_lotteryOpenSfcDetail){
                _lotteryOpenSfcDetail = [JddLotteryOpenDetailSFCViewController sharedInstance];
            }
            _lotteryOpenSfcDetail.fromController = fromController;
            _lotteryOpenSfcDetail.realResult =(NSString*)userInfo;
            _lotteryOpenSfcDetail.issue = (NSString*)userInfo2;
            [self pushViewController:_lotteryOpenSfcDetail];
            break;
        case CONTROLLER_SPORT_RESULT:
            if (!_sportResultController) {
                _sportResultController = [JddSportResultController sharedInstance];
            }
            _sportResultController.fromController = fromController;
            [self pushViewController:_sportResultController];
            break;
        case CONTROLLER_JCBB_RESULT:
            if (!_jclqResultController) {
                _jclqResultController = [JddJclqResultController sharedInstance];
            }
            _jclqResultController.fromController = fromController;
            [self pushViewController:_jclqResultController];
            break;
        case CONTROLLER_BD_RESULT:
            if (!_kjinfoBDResultController) {
                _kjinfoBDResultController = [JddKjinfoBDResultController sharedInstance];
            }
            _kjinfoBDResultController.fromController = fromController;
            [self pushViewController:_kjinfoBDResultController];
            break;
        case CONTROLLER_LOTTERY_OPEN_LIST:
            if (!_lotteryOpenListViewController) {
                _lotteryOpenListViewController = [JddLotteryOpenListViewController sharedInstance];
            }
            _lotteryOpenListViewController.fromController = fromController;
            _lotteryOpenListViewController.type = [NSNumber numberWithInt:[userInfo intValue]];
            [self pushViewController:_lotteryOpenListViewController];
            break;
        case CONTROLLER_ABOUT:
            if (!_aboutController) {
                _aboutController = [JddAboutViewController sharedInstance];
            }
            _aboutController.fromController = fromController;
            [self pushViewController:_aboutController];
            break;
        case CONTROLLER_CONTACT_US:
            if (!_contactUsController) {
                _contactUsController = [JddContactUsViewController sharedInstance];
            }
            _contactUsController.fromController = fromController;
            [self pushViewController:_contactUsController];
            break;
        case CONTROLLER_HOW_TO_PLAY_SSQ:
            if (!_howToPlaySSQController) {
                _howToPlaySSQController = [JddHowToPlaySSQViewController sharedInstance];
            }
            _howToPlaySSQController.fromController = fromController;
            [self pushViewController:_howToPlaySSQController];
            break;
        case CONTROLLER_BACK:
            if (!_backViewController) {
                _backViewController = [JddBackViewController sharedInstance];
            }
            _backViewController.fromController = fromController;
            [self pushViewController:_backViewController];
            break;
        case CONTROLLER_BIND_USER:
            if (!_bindUserViewController) {
                _bindUserViewController = [JddBindUserViewController sharedInstance];
            }
            _bindUserViewController.fromController = fromController;
            [self pushViewController:_bindUserViewController];
            break;
        case CONTROLLER_RE_BIND_MOBILE:
            if (!_reBindMobileContoller) {
                _reBindMobileContoller = [JddBindMobileViewController sharedInstance];
            }
            _reBindMobileContoller.fromController = fromController;
            [self pushViewController:_reBindMobileContoller];
            break;
        case CONTROLLER_NOTICE_DETAIL:
            _noticeDetail = [[JddNoticeDetailViewController alloc] init];
            _noticeDetail.fromController = fromController;
            _noticeDetail.noticeId = (NSString*)userInfo;
            [self pushViewController:_noticeDetail];
            break;
        case CONTROLLER_TOGETHER_BUY:
            if (!_togetherBuy) {
                _togetherBuy = [JddTogetherBuyViewController sharedInstance];
            }
            _togetherBuy.fromController = fromController;
            [self pushViewController:_togetherBuy];
            break;
        case CONTROLLER_TOGETHER_BUY_DETAIL:
            _togetherBuyDetail = [[JddTogetherBuyViewControllerDetail alloc] init];
            _togetherBuyDetail.fromController = fromController;
            _togetherBuyDetail.realString = (NSString*)userInfo;
            _togetherBuyDetail.buyHallData = (NSDictionary *)userInfo2;
            [self pushViewController:_togetherBuyDetail];
            break;
        case CONTROLLER_PICK_NUM_11YDJ:
            if (!_pickNum11YDJViewController) {
                _pickNum11YDJViewController = [JddPickNum11YDJViewController sharedInstance];
            }
            _pickNum11YDJViewController.fromController = fromController;
            [self pushViewController:_pickNum11YDJViewController];
            break;
        case CONTROLLER_PICK_NUM_11YDJ_LIST:
            if (!_pickNum11YDJListViewController) {
                _pickNum11YDJListViewController = [JddPickNum11YDJListViewController sharedInstance];
            }
            [_pickNum11YDJListViewController viewDidLoad];
            _pickNum11YDJListViewController.PlayMethodTemp = [userInfo2 intValue];
            [_pickNum11YDJListViewController numberFromArray:(NSArray *)userInfo];
            
            _pickNum11YDJListViewController.fromController = fromController;
            [self pushViewController:_pickNum11YDJListViewController];
            break;
        case CONTROLLER_PICK_NUM_CQSS:
            _pickNumCQSSViewController = [[JddPickNumCQSSViewController alloc] init];
            _pickNumCQSSViewController.fromController = fromController;
            [self pushViewController:_pickNumCQSSViewController];
            break;
        case CONTROLLER_PICK_NUM_CQSS_LIST:
            if (!_pickNumCQSSListViewController) {
                _pickNumCQSSListViewController = [JddPickNumCQSSListViewController sharedInstance];
            }
            _pickNumCQSSListViewController.playNameTemp = userInfo2;
            [_pickNumCQSSListViewController numberFromArray:(NSArray *)userInfo];
            _pickNumCQSSListViewController.fromController = fromController;
            [self pushViewController:_pickNumCQSSListViewController];
            break;
        case CONTROLLER_PICK_NUM_HH_SELECT:
            _pickNumSportViewHHSelectController = [[JddPickNumSportViewHHSelectController alloc] init];
            _pickNumSportViewHHSelectController.MatchCell = (NSDictionary *)userInfo;
            _pickNumSportViewHHSelectController.arr = (NSArray *)userInfo2;
            _pickNumSportViewHHSelectController.fromController = fromController;
            [self pushViewController:_pickNumSportViewHHSelectController];
            break;
        case CONTROLLER_BASKET_BALL_HH_SELECT:
            _basketBallHHSelectController = [[JddBasketBallHHSelectController alloc] init];
            _basketBallHHSelectController.MatchCell = (NSDictionary *)userInfo;
            _basketBallHHSelectController.arr = (NSArray *)userInfo2;
            _basketBallHHSelectController.fromController = fromController;
            [self pushViewController:_basketBallHHSelectController];
            break;
        case CONTROLLER_READ_REGISTER_PROTOCOL:
            _readRegisterProtocolViewController = [[JddReadRegisterProtocolViewController alloc] init];
            _readRegisterProtocolViewController.fromController = fromController;
            [self pushViewController:_readRegisterProtocolViewController];
            break;
        case CONTROLLER_READ_LOTTERY_PROTOCOL:
            _readLotteryProtocolViewController = [[JddReadLotteryProtocolViewController alloc] init];
            _readLotteryProtocolViewController.fromController = fromController;
            [self pushViewController:_readLotteryProtocolViewController];
            break;
        case CONTROLLER_USERCENTER_SAFECENTER:
            _safeCenterProtocolViewController = [[JddSafeCenterViewController alloc] init];
            _safeCenterProtocolViewController.fromController = fromController;
            [self pushViewController:_safeCenterProtocolViewController];
            break;
        case CONTROLLER_MORE_CUSTOMER_SERVICEl:
            _customerServiceViewController = [[JddCustomerServiceViewController alloc] init];
            _customerServiceViewController.fromController = fromController;
            _customerServiceViewController.webUrlString = userInfo;
            [self pushViewController:_customerServiceViewController];
        case CONTROLLER_FIVE_MATCH:
            //五大联赛
            if ([JddCommonFunction isLogin]) {
                if (!_fiveMatchCtl) {
                    _fiveMatchCtl = [[FiveMatchViewController alloc] init];
                }
            }else{
                _fiveMatchCtl = [[FiveMatchViewController alloc] init];
            }
            
            _fiveMatchCtl.fromController = fromController;
            
            [self pushViewController:_fiveMatchCtl];
            break;
        case CONTROLLER_LOOKFOR_PASSWORD:
            _findPassword = [[LookForPasswordViewController alloc] init];
            _findPassword.fromController = fromController;
            _findPassword.userName = (NSString *)userInfo;
            [self pushViewController:_findPassword];
            break;
        case CONTROLLER_CONFIRM:
            _confirmationController = [[ConfirmationViewController alloc] init];
            _confirmationController.fromController = fromController;
            _confirmationController.userName = (NSString *)userInfo;
            _confirmationController.phoneNum = (NSString *)userInfo2;
            [self pushViewController:_confirmationController];
            break;
        case CONTROLLER_CHANGEPWD:
            _changepwdController = [[JddChangePwdViewController alloc] init];
            _changepwdController.fromController = fromController;
            _changepwdController.userName = (NSString *)userInfo;
            _changepwdController.phoneNum = (NSString *)userInfo2;
            [self pushViewController:_changepwdController];
            break;
        default:
            break;
    }
}


-(void)indexViewController:(UIViewController *)viewController{
    viewController.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(refresh2:) ];
}

-(void)reflashViewController:(UIViewController *)viewController{
    viewController.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh2)];
}

-(void)popToRootViewController{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

-(void)popToBackViewController{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)setViewControllerClear
{
    NSArray *orignalControllers = [self.navigationController viewControllers];
    NSMutableArray *newControllers = [NSMutableArray arrayWithCapacity:1];
    for (UIViewController *inController in orignalControllers) {
        if ([inController class] == [JddLotteryHallViewController class]|| [inController class] == [JddTogetherBuyViewController class] || [inController class] == [JddLotteryOpenViewController class] || [inController class] == [JddScoreViewController class] || [inController class] == [JddUserCenterViewController class]) {
            [newControllers removeAllObjects];
            [newControllers addObject:inController];
        }
    }
    self.navigationController.viewControllers = newControllers;
}

- (void)pushViewController:(UIViewController*)viewController animated:(BOOL)animated
{
    
    NSArray *orignalControllers = [self.navigationController viewControllers];
    //阻止tag重新进入
    UIViewController *inController = [orignalControllers lastObject];
    if ([inController class] == [viewController class]){
        return ;
    }
    
    if(((JddBaseViewController*)viewController).fromController == nil){
        [self setViewControllerClear];
    }
    
    //如果navigationController.viewControllers存在这个类 就pop出来
    if([[self.navigationController viewControllers] containsObject:viewController])
    {
        viewController.hidesBottomBarWhenPushed = YES;
        [self.navigationController popToViewController:viewController animated:YES];
    } else {
        //取消主界面切换时的动画效果
        if ([viewController class] == [JddLotteryHallViewController class] || [viewController class] == [JddTogetherBuyViewController class] || [viewController class] == [JddLotteryOpenViewController class] || [viewController class] == [FiveMatchViewController class] || [viewController class] == [JddUserCenterViewController class]) {
            [self.navigationController pushViewController:viewController animated:NO];
        } else {
            [self.navigationController pushViewController:viewController animated:animated];
        }
    }
}

- (void)pushViewController:(UIViewController*)viewController
{
    
    NSArray *orignalControllers = [self.navigationController viewControllers];
    //阻止tag重新进入
    UIViewController *inController = [orignalControllers lastObject];
    if ([inController class] == [viewController class]){
        return ;
    }
    
    if(((JddBaseViewController*)viewController).fromController == nil){
       [self setViewControllerClear];
    }

    //如果navigationController.viewControllers存在这个类 就pop出来
    if([[self.navigationController viewControllers] containsObject:viewController])
    {
        viewController.hidesBottomBarWhenPushed = YES;
        [self.navigationController popToViewController:viewController animated:YES];
    } else {
        //取消主界面切换时的动画效果
        if ([viewController class] == [JddLotteryHallViewController class] || [viewController class] == [JddTogetherBuyViewController class] || [viewController class] == [JddLotteryOpenViewController class] || [viewController class] == [FiveMatchViewController class] || [viewController class] == [JddUserCenterViewController class]) {
            [self.navigationController pushViewController:viewController animated:NO];
        } else {
            [self.navigationController pushViewController:viewController animated:YES];
        }
    }
}

- (void)removeViewController:(UIViewController*)viewController{
    if ([[self.navigationController viewControllers] containsObject:viewController]) {
        NSArray *orignalControllers = [self.navigationController viewControllers];
        NSMutableArray *newControllers = [NSMutableArray arrayWithCapacity:[orignalControllers count]];
        for (UIViewController *inController in orignalControllers) {
            if (inController != viewController) {
                [newControllers addObject:inController];
            }
        }
        [self.navigationController setViewControllers:newControllers];
    }
}

@end
